//
//  LBNavigationController.m
//  app
//
//  Created by LINAICAI on 16/5/3.
//  Copyright © 2016年 广东联结电子商务有限公司. All rights reserved.
//

#import "LBNavigationController.h"

@interface LBNavigationController ()

@end

@implementation LBNavigationController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

{
    UIViewController *vc = self.topViewController;
    return [vc shouldAutorotateToInterfaceOrientation:toInterfaceOrientation];
    
}

- (BOOL)shouldAutorotate

{
    UIViewController *vc = self.topViewController;
    return [vc shouldAutorotate];
    
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations

{   UIViewController *vc = self.topViewController;
    return [vc supportedInterfaceOrientations];//只支持这一个方向(正常的方向)
}
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self.navigationBar setBackgroundImage:[[UIImage imageNamed:@"LBBaseController.bundle/lb_bar_bg.png"]resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeStretch] forBarMetrics:UIBarMetricsDefault];
    [self.navigationBar setTintColor:[UIColor whiteColor]];
    [self.navigationBar setTranslucent:NO];
    [self.navigationBar setBarStyle:UIBarStyleDefault];
    [self.navigationBar setTitleTextAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:18],
                                                          NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    //自定义返回按钮
    UIImage *image = [[UIImage imageNamed:@"LBBaseController.bundle/lb_bar_item_back.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [self.navigationBar setBackIndicatorImage:image];
    [self.navigationBar setBackIndicatorTransitionMaskImage:image];
    if (@available(iOS 11.0, *)) {
        
    } else {
        [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(NSIntegerMin, NSIntegerMin) forBarMetrics:UIBarMetricsDefault];
        // Fallback on earlier versions
    }
    // Do any additional setup after loading the view.
}
- (nullable UIViewController *)childViewControllerForStatusBarHidden{
    return self.topViewController;
}
-(UIViewController *)childViewControllerForStatusBarStyle
{
    return self.topViewController;
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{

    if (self.childViewControllers.count) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    
    [super pushViewController:viewController animated:animated];
    
}

@end
